package com.colorfruit.admin.control.config;

import com.colorfruit.framework.mybatis.BaseMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;

import java.util.Properties;

/**
 * 业务描述：
 *
 * @Auther: chenjiayuan
 * @Date: create in 2018/7/3 21
 * @Description:
 */
@AutoConfigureAfter(MybatisConfig.class)
@Configuration
@Slf4j
public class MapperScanConfig {
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        log.info("sqlSessionTemplate1() begin");
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory1");
        mapperScannerConfigurer.setBasePackage("com.colorfruit.admin.business.dao");
        Properties properties = new Properties();
        // 这里要特别注意，不要把MyMapper放到 basePackage 中，也就是不能同其他Mapper一样被扫描到。
        properties.setProperty("mappers", BaseMapper.class.getName());
        properties.setProperty("notEmpty", "false");
        properties.setProperty("IDENTITY", "MYSQL");
        return mapperScannerConfigurer;
    }
}
